package com.microservice.demo.client.service;

import com.einwin.framework.model.ResponseData;
import com.einwin.framework.model.ResponseCode;
import com.microservice.demo.api.DemoInterface;
import com.microservice.demo.api.DemoRemoteService;
import com.microservice.demo.api.InputParameter;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Created by fqiang on 4/21/17.
 */

@FeignClient(name = DemoInterface.SERVICE_NAME, fallback=DemoService.HystrixClientFallback.class)
public interface DemoService extends DemoRemoteService {

//    @RequestMapping(value = "/demo/index")
//    public ResponseData index(@RequestBody InputParameter in);
//
    @Component
    class HystrixClientFallback implements DemoService
    {
        @Override
        public ResponseData index(@RequestBody InputParameter abc) {
            System.out.println("DomeClient  fallback input----- - "+abc.getId()+" "+abc.getName()+ "  "+this.getClass());
            return new ResponseData(ResponseCode.UNKOWN_EXCEPTION);
        }
    }
}
